package com.zlm.tools.client;

import cn.hutool.core.util.ArrayUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.zlm.tools.request.BaseRequest;
import com.zlm.tools.request.GoodsRequest;
import com.zlm.tools.response.BaseResponse;
import com.zlm.tools.response.GoodsResponse;
import org.apache.commons.compress.utils.Lists;

import java.util.Arrays;

/**
 * {@code }
 *
 * @author zlm
 * @since 2025/6/24
 */
public class JdClient {

    public <T extends BaseResponse> T execute(BaseRequest<T> request){
        String result = HttpUtil.post("http://api.m.jd.com/api", JSONUtil.toJsonStr(request));
        return JSONUtil.toBean(result, request.getResponseType());
    }

    public static void main(String[] args) {
        JdClient client = new JdClient();
        GoodsRequest goodsRequest = new GoodsRequest();
        goodsRequest.setGoods(Arrays.asList("100008", "100009"));
        goodsRequest.setFunctionId("goods_async");
        GoodsResponse response = client.execute(goodsRequest);
        System.out.println( response);

    }
}
